package com.cafe.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.malamute.core.entity.BaseEntity;

/**
 * @Description 订单实体
 * @version v1.0
 */
@Entity
@Table(name = "T_CAFE_ORDER")
public class Order extends BaseEntity {
	private String name;// 订单名
	private String serialNum;// 订单序列号
	// 添加表的一对多的关联
	// @OneToMany(targetEntity = Product.class, mappedBy = "order")
	// private List<Product> products;// 定的菜单列表

	@OneToMany(targetEntity = OrderProduct.class, mappedBy = "order",fetch=FetchType.LAZY,cascade = CascadeType.ALL)
	
	private List<OrderProduct> orderProducts;

	@ManyToOne(targetEntity = Customer.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "customer_id")
	private Customer customer;

	private String area;// 发送地址

	@Enumerated(value = EnumType.ORDINAL)
	private OrderState state = OrderState.CREATE;

	private float cost;

	// TODO：订单状态

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	/**
	 * 获取name
	 * 
	 * @return name
	 */

	public String getName() {
		return name;
	}

	/**
	 * 设置name
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取serialNum
	 * 
	 * @return serialNum
	 */

	public String getSerialNum() {
		return serialNum;
	}

	/**
	 * 设置serialNum
	 * 
	 * @param serialNum
	 */
	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}

	// public List<Product> getProducts() {
	// return products;
	// }
	//
	// public void setProducts(List<Product> products) {
	// this.products = products;
	// }

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public List<OrderProduct> getOrderProducts() {
		return orderProducts;
	}

	public void setOrderProducts(List<OrderProduct> orderProducts) {
		this.orderProducts = orderProducts;
	}

	public OrderState getState() {
		return state;
	}

	public void setState(OrderState state) {
		this.state = state;
	}

	public float getCost() {
		return cost;
	}

	public void setCost(float cost) {
		this.cost = cost;
	}

}
